﻿Option Explicit On
Imports System.Drawing.Color
Imports System.Xml

Public Class Item

    Implements ICloneable

    Public name As String
    Public str As Double
    Public ap As Double
    Public crit As Double
    Public haste As Double
    Public arp As Double
    Public agi As Double
    Public exp As Double
    Public hit As Double
    Public armor As Double
    Public socketcolor(0 To 2) As Integer
    Public socketbonus As Double
    Public socketstat As Integer
    Public source As String
    Public ilvl As Double
    Public unique As Boolean
    Public procvalue As Double
    Public procstat As Integer
    Public procuptime As Double
    Public weptype As Integer
    Public wepdps As Double
    Public wepspeed As Double
    Public wephand As Integer
    Public wowheadID As Double

    Enum wephands
        none = 0
        onehand = 1
        mainhand = 2
        offhand = 3
    End Enum

    Enum weptypes
        none = 0
        axe = 1
        mace = 2
        sword = 3
        polearm = 4
    End Enum

    Enum stats
        none = 0
        str = 1
        ap = 2
        crit = 3
        haste = 4
        arp = 5
        agi = 6
        exp = 7
        hit = 8
    End Enum

    Enum colors
        none = 0
        red = 1
        yellow = 2
        blue = 3
        orange = 4
        green = 5
        purple = 6
        prismatic = 7
    End Enum

    Public Function clone() As Object Implements System.ICloneable.Clone
        Try
            Return New Item() With {.name = name, .str = str, .ap = ap, .crit = crit, .haste = haste, .arp = arp, .agi = agi, .exp = exp, .hit = hit, .armor = armor, .socketcolor = socketcolor.Clone, .socketbonus = socketbonus, .socketstat = socketstat, .ilvl = ilvl, .unique = unique, .procvalue = procvalue, .procstat = procstat, .procuptime = procuptime, .weptype = weptype, .wepspeed = wepspeed, .wepdps = wepdps, .wephand = wephand, .source = source, .wowheadID = wowheadID}
        Catch ex As Threading.ThreadAbortException
            Return New Item() With {.name = name, .str = str, .ap = ap, .crit = crit, .haste = haste, .arp = arp, .agi = agi, .exp = exp, .hit = hit, .armor = armor, .socketcolor = socketcolor.Clone, .socketbonus = socketbonus, .socketstat = socketstat, .ilvl = ilvl, .unique = unique, .procvalue = procvalue, .procstat = procstat, .procuptime = procuptime, .weptype = weptype, .wepspeed = wepspeed, .wepdps = wepdps, .wephand = wephand, .source = source, .wowheadID = wowheadID}
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Sub setColor(ByVal socketIndex As Integer, ByVal inColor As String)
        Try
            Select Case inColor
                Case "Red"
                    socketcolor(socketIndex) = 1
                Case "Yellow"
                    socketcolor(socketIndex) = 2
                Case "Blue"
                    socketcolor(socketIndex) = 3
                Case "Orange"
                    socketcolor(socketIndex) = 4
                Case "Green"
                    socketcolor(socketIndex) = 5
                Case "Purple"
                    socketcolor(socketIndex) = 6
                Case "Prismatic"
                    socketcolor(socketIndex) = 7
                Case "None"
                    socketcolor(socketIndex) = 0
            End Select
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Function getColor(ByVal socketIndex As Integer) As String
        Try
            Select Case socketcolor(socketIndex)
                Case 0
                    getColor = "None"
                Case 1
                    getColor = "Red"
                Case 2
                    getColor = "Yellow"
                Case 3
                    getColor = "Blue"
                Case 4
                    getColor = "Orange"
                Case 5
                    getColor = "Green"
                Case 6
                    getColor = "Purple"
                Case 7
                    getColor = "Prismatic"
                Case Else
                    getColor = "None"
            End Select
        Catch ex As Threading.ThreadAbortException
            getColor = "None"
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Function getUnique_YN() As String
        Try
            If unique = True Then
                getUnique_YN = "Yes"
            Else
                getUnique_YN = "No"
            End If
        Catch ex As Threading.ThreadAbortException
            getUnique_YN = "No"
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Function RGBColor(ByVal socketIndex As Integer) As Color
        Try
            Select Case socketcolor(socketIndex)
                Case 0 ' None (Error)
                    RGBColor = FromArgb(200, 200, 200)
                Case 1 'Red
                    RGBColor = FromArgb(255, 0, 0)
                Case 2 'Yellow
                    RGBColor = FromArgb(255, 255, 0)
                Case 3 'Blue
                    RGBColor = FromArgb(0, 0, 255)
                Case 4 'Orange
                    RGBColor = FromArgb(255, 153, 0)
                Case 5 'Green
                    RGBColor = FromArgb(0, 255, 0)
                Case 6 'Purple
                    RGBColor = FromArgb(255, 0, 255)
                Case 7 'Prismatic
                    RGBColor = FromArgb(255, 255, 255)
                Case Else ' Error Case
                    RGBColor = FromArgb(255, 255, 255)
            End Select
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Sub setSocketStat(ByVal stat As String)
        Try
            Select Case stat
                Case "None"
                    socketstat = 0
                Case "Str"
                    socketstat = 1
                Case "AP"
                    socketstat = 2
                Case "Crit"
                    socketstat = 3
                Case "Haste"
                    socketstat = 4
                Case "ArP"
                    socketstat = 5
                Case "Agi"
                    socketstat = 6
                Case "Exp"
                    socketstat = 7
                Case "Hit"
                    socketstat = 8
                Case Else
                    socketstat = 0
            End Select
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Function getSocketStat() As String
        Try
            Select Case socketstat
                Case 0
                    getSocketStat = "None"
                Case 1
                    getSocketStat = "Str"
                Case 2
                    getSocketStat = "AP"
                Case 3
                    getSocketStat = "Crit"
                Case 4
                    getSocketStat = "Haste"
                Case 5
                    getSocketStat = "ArP"
                Case 6
                    getSocketStat = "Agi"
                Case 7
                    getSocketStat = "Exp"
                Case 8
                    getSocketStat = "Hit"
                Case Else
                    getSocketStat = "None"
            End Select
        Catch ex As Threading.ThreadAbortException
            getSocketStat = "None"
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Function getprocStat() As String
        Try
            Select Case procstat
                Case 0
                    getprocStat = "None"
                Case 1
                    getprocStat = "Str"
                Case 2
                    getprocStat = "AP"
                Case 3
                    getprocStat = "Crit"
                Case 4
                    getprocStat = "Haste"
                Case 5
                    getprocStat = "ArP"
                Case 6
                    getprocStat = "Agi"
                Case 7
                    getprocStat = "Exp"
                Case 8
                    getprocStat = "Hit"
                Case Else
                    getprocStat = "None"
            End Select
        Catch ex As Threading.ThreadAbortException
            getprocStat = "None"
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Function getWepHand() As String
        Try
            Select Case wephand
                Case 0
                    getWepHand = "None"
                Case 1
                    getWepHand = "One Hand"
                Case 2
                    getWepHand = "Main Hand"
                Case 3
                    getWepHand = "Off Hand"
                Case Else
                    getWepHand = "None"
            End Select
        Catch ex As Threading.ThreadAbortException
            getWepHand = "None"
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Function getWepType() As String
        Try
            Select Case weptype
                Case 0
                    getWepType = "None"
                Case 1
                    getWepType = "Axe"
                Case 2
                    getWepType = "Mace"
                Case 3
                    getWepType = "Sword"
                Case 4
                    getWepType = "Polearm"
                Case Else
                    getWepType = "None"
            End Select
        Catch ex As Threading.ThreadAbortException
            getWepType = "None"
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Sub setProcStat(ByVal stat As String)
        Try
            Select Case stat
                Case "None"
                    procstat = 0
                Case "Str"
                    procstat = 1
                Case "AP"
                    procstat = 2
                Case "Crit"
                    procstat = 3
                Case "Haste"
                    procstat = 4
                Case "ArP"
                    procstat = 5
                Case "Agi"
                    procstat = 6
                Case "Exp"
                    procstat = 7
                Case "Hit"
                    procstat = 8
                Case Else
                    procstat = 0
            End Select
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Sub setWepType(ByVal wep As String)
        Try
            Select Case wep
                Case "Axe"
                    weptype = weptypes.axe
                Case "Sword"
                    weptype = weptypes.sword
                Case "Mace"
                    weptype = weptypes.mace
                Case "Polearm"
                    weptype = weptypes.polearm
                Case Else
                    weptype = 0
            End Select
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Sub setWepHand(ByVal hand As String)
        Try
            Select Case hand
                Case "One Hand"
                    wephand = wephands.onehand
                Case "Main Hand"
                    wephand = wephands.mainhand
                Case "Off Hand"
                    wephand = wephands.offhand
                Case Else
                    wephand = 0
            End Select
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Sub Clear()
        Try
            ' Clears the value out of everything.
            name = ""
            str = 0
            ap = 0
            crit = 0
            haste = 0
            arp = 0
            agi = 0
            exp = 0
            hit = 0
            armor = 0
            socketcolor(0) = 0
            socketcolor(1) = 0
            socketcolor(2) = 0
            socketbonus = 0
            socketstat = 0
            source = ""
            ilvl = 0
            unique = False
            procvalue = 0
            procstat = 0
            procuptime = 0
            weptype = 0
            wepdps = 0
            wepspeed = 0
            wephand = 0
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Sub LoadFromNode(ByVal m_node As XmlNode, ByVal slot As String)
        Try
            Select Case LCase(slot)
                Case "head", "shoulder", "chest", "hand", "leg", "neck", "back", "wrist", "waist", "foot"
                    name = m_node.Attributes.GetNamedItem("name").Value
                    str = Double.Parse(m_node.ChildNodes.Item(0).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    ap = Double.Parse(m_node.ChildNodes.Item(1).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    crit = Double.Parse(m_node.ChildNodes.Item(2).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    haste = Double.Parse(m_node.ChildNodes.Item(3).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    arp = Double.Parse(m_node.ChildNodes.Item(4).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    agi = Double.Parse(m_node.ChildNodes.Item(5).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    exp = Double.Parse(m_node.ChildNodes.Item(6).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    hit = Double.Parse(m_node.ChildNodes.Item(7).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    armor = Double.Parse(m_node.ChildNodes.Item(8).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setColor(0, m_node.ChildNodes.Item(9).InnerText)
                    setColor(1, m_node.ChildNodes.Item(10).InnerText)
                    setColor(2, m_node.ChildNodes.Item(11).InnerText)
                    socketbonus = Double.Parse(m_node.ChildNodes.Item(12).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setSocketStat(m_node.ChildNodes.Item(13).InnerText)
                    source = m_node.ChildNodes.Item(14).InnerText
                    ilvl = Double.Parse(m_node.ChildNodes.Item(15).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    wowheadID = Double.Parse(m_node.ChildNodes.Item(16).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                Case "finger"
                    name = m_node.Attributes.GetNamedItem("name").Value
                    str = Double.Parse(m_node.ChildNodes.Item(0).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    ap = Double.Parse(m_node.ChildNodes.Item(1).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    crit = Double.Parse(m_node.ChildNodes.Item(2).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    haste = Double.Parse(m_node.ChildNodes.Item(3).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    arp = Double.Parse(m_node.ChildNodes.Item(4).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    agi = Double.Parse(m_node.ChildNodes.Item(5).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    exp = Double.Parse(m_node.ChildNodes.Item(6).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    hit = Double.Parse(m_node.ChildNodes.Item(7).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    armor = Double.Parse(m_node.ChildNodes.Item(8).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setColor(0, m_node.ChildNodes.Item(9).InnerText)
                    setColor(1, m_node.ChildNodes.Item(10).InnerText)
                    setColor(2, m_node.ChildNodes.Item(11).InnerText)
                    socketbonus = Double.Parse(m_node.ChildNodes.Item(12).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setSocketStat(m_node.ChildNodes.Item(13).InnerText)
                    source = m_node.ChildNodes.Item(14).InnerText
                    ilvl = Double.Parse(m_node.ChildNodes.Item(15).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    wowheadID = Double.Parse(m_node.ChildNodes.Item(16).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    unique = Convert.ToBoolean(m_node.ChildNodes.Item(17).InnerText)
                Case "trinket"
                    name = m_node.Attributes.GetNamedItem("name").Value
                    str = Double.Parse(m_node.ChildNodes.Item(0).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    ap = Double.Parse(m_node.ChildNodes.Item(1).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    crit = Double.Parse(m_node.ChildNodes.Item(2).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    haste = Double.Parse(m_node.ChildNodes.Item(3).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    arp = Double.Parse(m_node.ChildNodes.Item(4).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    agi = Double.Parse(m_node.ChildNodes.Item(5).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    exp = Double.Parse(m_node.ChildNodes.Item(6).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    hit = Double.Parse(m_node.ChildNodes.Item(7).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    armor = Double.Parse(m_node.ChildNodes.Item(8).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setColor(0, m_node.ChildNodes.Item(9).InnerText)
                    setColor(1, m_node.ChildNodes.Item(10).InnerText)
                    setColor(2, m_node.ChildNodes.Item(11).InnerText)
                    socketbonus = Double.Parse(m_node.ChildNodes.Item(12).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setSocketStat(m_node.ChildNodes.Item(13).InnerText)
                    source = m_node.ChildNodes.Item(14).InnerText
                    ilvl = Double.Parse(m_node.ChildNodes.Item(15).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    wowheadID = Double.Parse(m_node.ChildNodes.Item(16).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    procvalue = Double.Parse(m_node.ChildNodes.Item(17).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setProcStat(m_node.ChildNodes.Item(18).InnerText)
                    procuptime = Double.Parse(m_node.ChildNodes.Item(19).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                Case "twohand"
                    name = m_node.Attributes.GetNamedItem("name").Value
                    str = Double.Parse(m_node.ChildNodes.Item(0).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    ap = Double.Parse(m_node.ChildNodes.Item(1).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    crit = Double.Parse(m_node.ChildNodes.Item(2).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    haste = Double.Parse(m_node.ChildNodes.Item(3).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    arp = Double.Parse(m_node.ChildNodes.Item(4).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    agi = Double.Parse(m_node.ChildNodes.Item(5).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    exp = Double.Parse(m_node.ChildNodes.Item(6).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    hit = Double.Parse(m_node.ChildNodes.Item(7).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    armor = Double.Parse(m_node.ChildNodes.Item(8).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setColor(0, m_node.ChildNodes.Item(9).InnerText)
                    setColor(1, m_node.ChildNodes.Item(10).InnerText)
                    setColor(2, m_node.ChildNodes.Item(11).InnerText)
                    socketbonus = Double.Parse(m_node.ChildNodes.Item(12).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setSocketStat(m_node.ChildNodes.Item(13).InnerText)
                    source = m_node.ChildNodes.Item(14).InnerText
                    ilvl = Double.Parse(m_node.ChildNodes.Item(15).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    wowheadID = Double.Parse(m_node.ChildNodes.Item(16).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setWepType(m_node.ChildNodes.Item(17).InnerText)
                    wepdps = Double.Parse(m_node.ChildNodes.Item(18).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    wepspeed = Double.Parse(m_node.ChildNodes.Item(19).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                Case "onehand"
                    name = m_node.Attributes.GetNamedItem("name").Value
                    str = Double.Parse(m_node.ChildNodes.Item(0).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    ap = Double.Parse(m_node.ChildNodes.Item(1).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    crit = Double.Parse(m_node.ChildNodes.Item(2).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    haste = Double.Parse(m_node.ChildNodes.Item(3).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    arp = Double.Parse(m_node.ChildNodes.Item(4).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    agi = Double.Parse(m_node.ChildNodes.Item(5).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    exp = Double.Parse(m_node.ChildNodes.Item(6).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    hit = Double.Parse(m_node.ChildNodes.Item(7).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    armor = Double.Parse(m_node.ChildNodes.Item(8).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setColor(0, m_node.ChildNodes.Item(9).InnerText)
                    setColor(1, m_node.ChildNodes.Item(10).InnerText)
                    setColor(2, m_node.ChildNodes.Item(11).InnerText)
                    socketbonus = Double.Parse(m_node.ChildNodes.Item(12).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setSocketStat(m_node.ChildNodes.Item(13).InnerText)
                    source = m_node.ChildNodes.Item(14).InnerText
                    ilvl = Double.Parse(m_node.ChildNodes.Item(15).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    wowheadID = Double.Parse(m_node.ChildNodes.Item(16).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    unique = Convert.ToBoolean(m_node.ChildNodes.Item(17).InnerText)
                    setWepType(m_node.ChildNodes.Item(18).InnerText)
                    wepdps = Double.Parse(m_node.ChildNodes.Item(19).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    wepspeed = Double.Parse(m_node.ChildNodes.Item(20).InnerText, System.Globalization.CultureInfo.InvariantCulture)
                    setWepHand(m_node.ChildNodes.Item(21).InnerText)
            End Select
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Sub showStatic(ByVal grid As FlexCell.Grid, ByVal row As Integer, ByVal startCol As Integer, ByVal slot As String, ByVal showWowheadID As Boolean)
        Try
            With grid
                Select Case LCase(slot)
                    Case "head", "shoulder", "chest", "hand", "leg", "neck", "back", "wrist", "waist", "foot"
                        .Cell(row, startCol).Text = name
                        .Cell(row, startCol + 1).Text = str
                        .Cell(row, startCol + 2).Text = ap
                        .Cell(row, startCol + 3).Text = crit
                        .Cell(row, startCol + 4).Text = haste
                        .Cell(row, startCol + 5).Text = arp
                        .Cell(row, startCol + 6).Text = agi
                        .Cell(row, startCol + 7).Text = exp
                        .Cell(row, startCol + 8).Text = hit
                        .Cell(row, startCol + 9).Text = armor
                        .Cell(row, startCol + 10).Text = getColor(0)
                        .Cell(row, startCol + 11).Text = getColor(1)
                        .Cell(row, startCol + 12).Text = getColor(2)
                        .Cell(row, startCol + 13).Text = socketbonus
                        .Cell(row, startCol + 14).Text = getSocketStat()
                        .Cell(row, startCol + 15).Text = source
                        .Cell(row, startCol + 16).Text = ilvl
                        If showWowheadID = True Then
                            .Cell(row, startCol + 17).Text = wowheadID
                        End If

                        .Cell(row, startCol + 10).BackColor = RGBColor(0)
                        .Cell(row, startCol + 11).BackColor = RGBColor(1)
                        .Cell(row, startCol + 12).BackColor = RGBColor(2)
                        .Cell(row, startCol + 10).FontBold = True
                        .Cell(row, startCol + 11).FontBold = True
                        .Cell(row, startCol + 12).FontBold = True
                    Case "finger"
                        .Cell(row, startCol).Text = name
                        .Cell(row, startCol + 1).Text = getUnique_YN()
                        .Cell(row, startCol + 2).Text = str
                        .Cell(row, startCol + 3).Text = ap
                        .Cell(row, startCol + 4).Text = crit
                        .Cell(row, startCol + 5).Text = haste
                        .Cell(row, startCol + 6).Text = arp
                        .Cell(row, startCol + 7).Text = agi
                        .Cell(row, startCol + 8).Text = exp
                        .Cell(row, startCol + 9).Text = hit
                        .Cell(row, startCol + 10).Text = armor
                        .Cell(row, startCol + 11).Text = getColor(0)
                        .Cell(row, startCol + 12).Text = getColor(1)
                        .Cell(row, startCol + 13).Text = getColor(2)
                        .Cell(row, startCol + 14).Text = socketbonus
                        .Cell(row, startCol + 15).Text = getSocketStat()
                        .Cell(row, startCol + 16).Text = source
                        .Cell(row, startCol + 17).Text = ilvl
                        If showWowheadID = True Then
                            .Cell(row, startCol + 18).Text = wowheadID
                        End If

                        .Cell(row, startCol + 11).BackColor = RGBColor(0)
                        .Cell(row, startCol + 12).BackColor = RGBColor(1)
                        .Cell(row, startCol + 13).BackColor = RGBColor(2)
                        .Cell(row, startCol + 11).FontBold = True
                        .Cell(row, startCol + 12).FontBold = True
                        .Cell(row, startCol + 13).FontBold = True
                    Case "trinket"
                        .Cell(row, startCol).Text = name
                        .Cell(row, startCol + 1).Text = procvalue
                        .Cell(row, startCol + 2).Text = getprocStat()
                        .Cell(row, startCol + 3).Text = procuptime.ToString("###0.000")
                        .Cell(row, startCol + 4).Text = str
                        .Cell(row, startCol + 5).Text = ap
                        .Cell(row, startCol + 6).Text = crit
                        .Cell(row, startCol + 7).Text = haste
                        .Cell(row, startCol + 8).Text = arp
                        .Cell(row, startCol + 9).Text = agi
                        .Cell(row, startCol + 10).Text = exp
                        .Cell(row, startCol + 11).Text = hit
                        .Cell(row, startCol + 12).Text = armor
                        .Cell(row, startCol + 13).Text = getColor(0)
                        .Cell(row, startCol + 14).Text = getColor(1)
                        .Cell(row, startCol + 15).Text = getColor(2)
                        .Cell(row, startCol + 16).Text = socketbonus
                        .Cell(row, startCol + 17).Text = getSocketStat()
                        .Cell(row, startCol + 18).Text = source
                        .Cell(row, startCol + 19).Text = ilvl
                        If showWowheadID = True Then
                            .Cell(row, startCol + 20).Text = wowheadID
                        End If

                        .Cell(row, startCol + 13).BackColor = RGBColor(0)
                        .Cell(row, startCol + 14).BackColor = RGBColor(1)
                        .Cell(row, startCol + 15).BackColor = RGBColor(2)
                        .Cell(row, startCol + 13).FontBold = True
                        .Cell(row, startCol + 14).FontBold = True
                        .Cell(row, startCol + 15).FontBold = True
                    Case "twohand"
                        .Cell(row, startCol).Text = name
                        .Cell(row, startCol + 1).Text = getWepType()
                        .Cell(row, startCol + 2).Text = wepdps.ToString("###0.0")
                        .Cell(row, startCol + 3).Text = wepspeed.ToString("0.00")
                        .Cell(row, startCol + 4).Text = str
                        .Cell(row, startCol + 5).Text = ap
                        .Cell(row, startCol + 6).Text = crit
                        .Cell(row, startCol + 7).Text = haste
                        .Cell(row, startCol + 8).Text = arp
                        .Cell(row, startCol + 9).Text = agi
                        .Cell(row, startCol + 10).Text = exp
                        .Cell(row, startCol + 11).Text = hit
                        .Cell(row, startCol + 12).Text = armor
                        .Cell(row, startCol + 13).Text = getColor(0)
                        .Cell(row, startCol + 14).Text = getColor(1)
                        .Cell(row, startCol + 15).Text = getColor(2)
                        .Cell(row, startCol + 16).Text = socketbonus
                        .Cell(row, startCol + 17).Text = getSocketStat()
                        .Cell(row, startCol + 18).Text = source
                        .Cell(row, startCol + 19).Text = ilvl
                        If showWowheadID = True Then
                            .Cell(row, startCol + 20).Text = wowheadID
                        End If

                        .Cell(row, startCol + 13).BackColor = RGBColor(0)
                        .Cell(row, startCol + 14).BackColor = RGBColor(1)
                        .Cell(row, startCol + 15).BackColor = RGBColor(2)
                        .Cell(row, startCol + 13).FontBold = True
                        .Cell(row, startCol + 14).FontBold = True
                        .Cell(row, startCol + 15).FontBold = True
                    Case "onehand"
                        .Cell(row, startCol).Text = name
                        .Cell(row, startCol + 1).Text = getWepType()
                        .Cell(row, startCol + 2).Text = getUnique_YN()
                        .Cell(row, startCol + 3).Text = getWepHand()
                        .Cell(row, startCol + 4).Text = wepdps.ToString("###0.0")
                        .Cell(row, startCol + 5).Text = wepspeed.ToString("0.00")
                        .Cell(row, startCol + 6).Text = str
                        .Cell(row, startCol + 7).Text = ap
                        .Cell(row, startCol + 8).Text = crit
                        .Cell(row, startCol + 9).Text = haste
                        .Cell(row, startCol + 10).Text = arp
                        .Cell(row, startCol + 11).Text = agi
                        .Cell(row, startCol + 12).Text = exp
                        .Cell(row, startCol + 13).Text = hit
                        .Cell(row, startCol + 14).Text = armor
                        .Cell(row, startCol + 15).Text = getColor(0)
                        .Cell(row, startCol + 16).Text = getColor(1)
                        .Cell(row, startCol + 17).Text = getColor(2)
                        .Cell(row, startCol + 18).Text = socketbonus
                        .Cell(row, startCol + 19).Text = getSocketStat()
                        .Cell(row, startCol + 20).Text = source
                        .Cell(row, startCol + 21).Text = ilvl
                        If showWowheadID = True Then
                            .Cell(row, startCol + 22).Text = wowheadID
                        End If

                        .Cell(row, startCol + 15).BackColor = RGBColor(0)
                        .Cell(row, startCol + 16).BackColor = RGBColor(1)
                        .Cell(row, startCol + 17).BackColor = RGBColor(2)
                        .Cell(row, startCol + 15).FontBold = True
                        .Cell(row, startCol + 16).FontBold = True
                        .Cell(row, startCol + 17).FontBold = True
                End Select
            End With
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Sub addSocket(ByVal color As colors)
        Try
            ' Add a socket.
            If Me.socketcolor(0) = colors.none Then
                Me.socketcolor(0) = color
            Else
                If Me.socketcolor(1) = colors.none Then
                    Me.socketcolor(1) = color
                Else
                    Me.socketcolor(2) = color
                End If
            End If
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Function numSockets() As Integer
        ' Returns an integer value representing
        ' the number of sockets that an item has.
        If socketcolor(0) = colors.none Then
            numSockets = 0
        ElseIf socketcolor(1) = colors.none Then
            numSockets = 1
        ElseIf socketcolor(2) = colors.none Then
            numSockets = 2
        Else
            numSockets = 3
        End If
    End Function
End Class
